package shs.controller;



import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import shs.bean.User;


@Slf4j
@RestController
public class HelloController {
    private final RedisTemplate redisTemplate;
    Logger logger=LoggerFactory.getLogger(getClass());

    public HelloController(@Qualifier("redisTemplate") RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    @GetMapping("/hello")
    public String hello(String a, String b){
        logger.warn("this{},{}",a,b);
        return "hello";
    }
    @GetMapping("increase")
    public String increase(){
        Long haha = redisTemplate.opsForValue().increment("haha");
        return "增加后的值"+haha;
    }

    /**
     *1.默认支持把对象写为json,因为默认web场景导入了jackson处理json的包；jackson-core
     * @return json
     */
    @GetMapping("/person")
    public User person(){
        User user = new User();
        user.setId("1");
        user.setName("nihao");

        return user;
    }
}
